﻿using System.Collections.Generic;

namespace ComicsDownloader.Engine
{
    public class CartoonRepository
    {
        #region singleton
        private static CartoonRepository _instance;

        public static CartoonRepository Instance
        {
            get
            {
                if (_instance == null)
                    _instance = new CartoonRepository();
                return _instance;
            }
        }

        private CartoonRepository()
        {
            Cartoons = new List<Cartoon>();

//            Cartoon cartoon = new Cartoon();
//            cartoon.Name = "멜랑꼴리";
//            cartoon.CartoonUrl = "http://stoo.asiae.co.kr/cartoon/ctlist.php?pg={0}&strForm=s_list&sc3=1&sc2=ing";
//            cartoon.PictureUrl = "http://stoo.asiae.co.kr/cartoon/ctview.htm?sc2=ing&sc3=1&id={0}&pg={1}&tpg={2}";
//            cartoon.Extension = ".jpg";
//            Cartoons.Add(cartoon);
            
            WebSite webSite = new WebSite(WebSite.Stoo, "스투");
            Cartoons.Add(AddCartoon(webSite, "멜랑꼴리", 1));
            Cartoons.Add(AddCartoon(webSite, "추리닝", 2));
            Cartoons.Add(AddCartoon(webSite, "4분 요리", 3));
            Cartoons.Add(AddCartoon(webSite, "꾸나꼬무이야기", 4));
            Cartoons.Add(AddCartoon(webSite, "짬 시즌 2", 5));
            Cartoons.Add(AddCartoon(webSite, "구로막차오뎅한개피", 6));
            Cartoons.Add(AddCartoon(webSite, "아이스께끼", 79));
            Cartoons.Add(AddCartoon(webSite, "독고리와인드", 97));
            Cartoons.Add(AddCartoon(webSite, "독고", 84));
            Cartoons.Add(AddCartoon(webSite, "NEW까까마까", 62));
            Cartoons.Add(AddCartoon(webSite, "올리고당", 87));
            Cartoons.Add(AddCartoon(webSite, "베리타스", 99));
            Cartoons.Add(AddCartoon(webSite, "소울", 100));
            Cartoons.Add(AddCartoon(webSite, "건달본색", 89));
            Cartoons.Add(AddCartoon(webSite, "미아리", 80));
            Cartoons.Add(AddCartoon(webSite, "프릭", 85));
            Cartoons.Add(AddCartoon(webSite, "엔젤", 91));
            Cartoons.Add(AddCartoon(webSite, "헬로좀비걸", 96));
            Cartoons.Add(AddCartoon(webSite, "꽃미남 게스트하우스 ", 98));
            Cartoons.Add(AddCartoon(webSite, "애니멀스쿨", 92));
            Cartoons.Add(AddCartoon(webSite, "보빙사", 90));
            Cartoons.Add(AddCartoon(webSite, "522", 95));
            Cartoons.Add(AddCartoon(webSite, "수사불패", 83));
            Cartoons.Add(AddCartoon(webSite, "활로", 76));
            Cartoons.Add(AddCartoon(webSite, "소치특집만화 ", 94));
            Cartoons.Add(AddCartoon(webSite, "알람", 88));
            Cartoons.Add(AddCartoon(webSite, "DISS프로야구", 93));
            Cartoons.Add(AddCartoon(webSite, "귀요환서", 77));
            Cartoons.Add(AddCartoon(webSite, "직도단혼", 75));
            Cartoons.Add(AddCartoon(webSite, "표류소녀", 78));
            Cartoons.Add(AddCartoon(webSite, "팡팡맨", 60));
            Cartoons.Add(AddCartoon(webSite, "2012 대선특집", 82));
            Cartoons.Add(AddCartoon(webSite, "총수", 57));
            Cartoons.Add(AddCartoon(webSite, "끗발 시즌3 죽어도 좋아", 67));
            Cartoons.Add(AddCartoon(webSite, "실화", 71));
            Cartoons.Add(AddCartoon(webSite, "떡정어게인 Ep.3", 70));
        }

        private Cartoon AddCartoon(WebSite webSite, string name, int id)
        {
            var cartoonUrl = "http://stoo.asiae.co.kr/cartoon/ctlist.php?pg={0}&strForm=s_list&sc3=" + id + "&sc2=ing";
            const string pictureUrl = "http://stoo.asiae.co.kr/cartoon/ctview.htm?sc2=ing&sc3=1&id={0}&pg={1}&tpg={2}";
            
            return new Cartoon(webSite, name, cartoonUrl, pictureUrl, ".jpg");
        }
        #endregion

        public List<Cartoon> Cartoons { get; private set; }
    }
}
